import { Router } from 'express';
import userRoutes from './users';
import authRoutes from './auth';
import paymentRoutes from './paymentRoutes';
import creditRoutes from './creditRoutes';
import ossRoutes from './ossRoutes';
import aiRoutes from './aiRoutes';

const router: Router = Router();

// API version prefix
const API_VERSION = '/v1';

// Health check for API
router.get('/health', (req, res) => {
  res.json({
    status: 'OK',
    message: 'API is working',
    timestamp: new Date().toISOString()
  });
});

// Route modules
router.use(`${API_VERSION}/auth`, authRoutes);
router.use(`${API_VERSION}/users`, userRoutes);
router.use(`${API_VERSION}/payments`, paymentRoutes);
router.use(`${API_VERSION}/credits`, creditRoutes);
router.use(`${API_VERSION}/oss`, ossRoutes);
router.use(`${API_VERSION}/ai`, aiRoutes);

// API info endpoint
router.get('/', (req, res) => {
  res.json({
    message: 'API v1',
    version: '1.0.0',
    endpoints: {
      auth: `${API_VERSION}/auth`,
      users: `${API_VERSION}/users`,
      payments: `${API_VERSION}/payments`,
      credits: `${API_VERSION}/credits`,
      oss: `${API_VERSION}/oss`,
      ai: `${API_VERSION}/ai`,
      health: '/health'
    }
  });
});

export default router;